package com.zghl.service.impl;

import com.zghl.dao.EquipmentDao;
import com.zghl.pojo.Equipment;
import com.zghl.service.EquipmentService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author:wangbosen
 * @Date:2020/7/27 11:00
 * Description
 */
@Service
public class EquipmentServiceImpl implements EquipmentService {

    @Resource
    private EquipmentDao equipmentDao;

    @Override
    public List<Equipment> EquipmentList(Map<String, Object> param) {
        List<Equipment> eqList = equipmentDao.EquipmentList(param);
        return eqList;
    }

    @Override
    public Integer AddByEquipment(Equipment equipment) {

        Equipment equipment1=new Equipment();

        BeanUtils.copyProperties(equipment,equipment1);

        Calendar now=Calendar.getInstance();

        now.setTime(new Date());

        equipment1.setPutDate(now.getTime());

        Integer integer = equipmentDao.AddByEquipment(equipment);

        if (integer>0){
            return 1;
        }
        return 0;
    }

    @Override
    public Integer deleteByEquipment(int EquipmentId) {
        Integer integer = equipmentDao.deleteByEquipment(EquipmentId);
        if (integer>0){
            return 1;
        }
        return 0;
    }

    @Override
    public Integer updateByEquipment(Equipment equipment) {
        Integer integer = equipmentDao.updateByEquipment(equipment);

        if (integer>0){
            return 1;
        }
        return 0;
    }
}
